﻿
class Program
{

    static void Main(string[] args)
    {
        M01();
    }




    static async Task M01()
    {
        using var client = new HttpClient();
        var filename = @"f:\temp\abc.pdf";
        var url = "http://192.168.1.81:8765/ThirdPartyApi/ThirdPart/UploadFileV2/CT1942800002";
        var appReferer = "http://192.168.1.81:8765";
        var appSecret = "5e1ae97840d64c619843a1f75f8c7504";
        var appId = "15942d35d47140a3b7f3a9d2dd3ba1a0";
        var method = "post";
        client.DefaultRequestHeaders.Add("HiAuthAppKey", appId);
        client.DefaultRequestHeaders.Add("HiAuthAppVersion", "V2.0");
        client.DefaultRequestHeaders.Add("HiAuthAppReferer", appReferer);
        var sign = GenerateSignature(url, method, "V2.0", appReferer, appSecret, filename, "", true);
        client.DefaultRequestHeaders.Add("HiAuthAppSignature", sign);
        var content = new StreamContent(File.OpenRead(filename));
        try
        {
            var response = await client.PostAsync(url, content);
            response.EnsureSuccessStatusCode();
            var readResult = await response.Content.ReadAsStreamAsync();
            Console.WriteLine(readResult);
        }
        catch (Exception exp)
        {
            Console.WriteLine(exp.ToString());
        }
        finally
        {
            content.Dispose();
        }
    }

    static string GenerateSignature(
        string url,
        string method,
        string version,
        string referer,
        string appSecurity,
        string filePath, string postBody, bool isUploadFile = false
    )
    {
        return "";
    }
}